<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="jakarta.tags.core" %>
<%@ taglib prefix="ujn" uri="http://ujn.edu.cn/common/"%>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName()
          + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML>
<html>
<!--用户导航栏-->
<!--请勿随意修改该 demo 文件, 请复制后修改名称使用-->
<!--该 demo 仅规定了导航栏样式，css文件入js文件均不齐全，请根据需要添加-->
<!--css和 js具体添加方式和缺少文件参考老师发的 lab3 或 exam3 -->
<!--其他未尽事宜请阅读《停车场.md》文件-->

<head>
  <title>demo.jsp</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <!-- 引入css样式文件 -->
      <!-- Bootstrap Core CSS -->
      <link href="<%=basePath%>css/bootstrap.css" rel="stylesheet"/>
      <!-- Bootstrap-grid CSS -->
      <link href="<%=basePath%>css/bootstrap-grid.css" rel="stylesheet"/>
      <!-- Bootstrap-reboot CSS -->
      <link href="<%=basePath%>css/bootstrap-reboot.css" rel="stylesheet"/>
      <!-- MetisMenu CSS -->
      <link href="<%=basePath%>css/metisMenu.min.css" rel="stylesheet" />
      <!-- DataTables CSS -->
      <link href="<%=basePath%>css/dataTables.bootstrap.css" rel="stylesheet" />
      <!-- Custom CSS -->
      <link href="<%=basePath%>css/sb-admin-2.css" rel="stylesheet" />
      <!-- Custom Fonts -->
      <link href="<%=basePath%>css/font-awesome.min.css" rel="stylesheet" type="text/css" />
      <link href="<%=basePath%>css/boot-crm.css" rel="stylesheet" type="text/css" />
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>

<div>
  <nav class="navbar navbar-expand-lg navbar-dark " style="background-color:#81D8CF;;">
      <img src="imges/logo.jpg" class="rounded float-left" alt="Logo" height="45" width="45">
    <div class="container" style="">
      <a class="navbar-brand" href="#">停车场管理系统</a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarText"
              aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarText">
          <ul class="navbar-nav mr-auto">
              <li class="nav-item">
                  <a class="nav-link " href="${pageContext.request.contextPath }/userself">个人信息</a>
              </li>
              <li class="nav-item">
                  <a class="nav-link " href="${pageContext.request.contextPath }/bookself">车位预定</a>
              </li>
              <li class="nav-item">
                  <a class="nav-link" href="${pageContext.request.contextPath}/payments">全部订单</a>
              </li>
              <li class="nav-item">
                  <a class="nav-link" href="${pageContext.request.contextPath}/coupon">优惠券</a>
              </li>
              <li class="nav-item">
                  <a class="nav-link" href="${pageContext.request.contextPath }/rateself">收费标准</a>
              </li>
              <li class="nav-item">
                  <a class="nav-link" href="${pageContext.request.contextPath }/vehicleself">车辆信息</a>
              </li>
              <li class="nav-item">
                  <a class="nav-link active" href="${pageContext.request.contextPath }/userequip">投诉反馈</a>
              </li>
          </ul>
        <span class="navbar-text">
          导航栏
        </span>
      </div>
    </div>
  </nav>
</div>



<div class="container">
    <h1>设备投诉<a href="${pageContext.request.contextPath }/userfeedback">我的建议</a></h1>
    <div class="p-2 bg-light border">
        <div class="panel panel-default">
                            <div class="panel-body">
                                <form class="form-inline" method="get"
                                      action="${pageContext.request.contextPath }/equipmentselect">
                                    <div class="form-group">
                                        <label for="equipmentName">设备名称</label>
                                        <input type="text" class="form-control" id="equipmentName" name="equipmentName"/>
                                    </div>
                                    <button type="submit" class="btn btn-primary">查询</button>
                                </form>
                            </div>
        </div>
        <table class="table table-bordered table-striped">
        	<thead>
        		<tr>
        			<th>编号</th>
        			<th>设备名称</th>
        			<th>设备状态</th>
        			<th>操作</th>
        		</tr>
        	</thead>
        	<tbody>
        	    <c:forEach items="${page.rows}" var="row">
        			<tr>
        				<td>${row.equipmentId}</td>
        				<td>${row.equipmentName}</td>
        				<td>${row.status}</td>
        				<td><center>
        					<a href="#" class="btn btn-primary" data-toggle="modal"
                                     data-target="#newmaintenancerecordDialog" onclick="clearMiantenanceRecord(${row.equipmentId})">报修</a>
        				</td>
        			</tr>
        		</c:forEach>
        	</tbody>
        </table>
               <div class="col-md-12 text-right">
                    <ujn:page url="${pageContext.request.contextPath }/userequip"/>
                </div>
    </div>
</div>
<!-- 创建模态框 -->
<div class="modal fade" id="newfeedbackDialog" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="myModalLabel1">新建建议</h4>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" id="new_feedback_form">
                    <div class="form-group">
                        <label for="new_userId" class="col-md-auto control-label">
                            用户编号
                        </label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="new_userId" placeholder="用户编号" name="userId" value="${userId}" readonly/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="new_content" class="col-md-auto control-label">建议内容</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="new_content" placeholder="建议内容" name="content" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="new_status" class="col-md-auto control-label">状态</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="new_status" placeholder="状态" name="status" value="未处理" readonly/>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="createFeedBack()">提交建议</button>
            </div>
        </div>
    </div>
</div>
<!-- 创建模态框 -->
<div class="modal fade" id="newmaintenancerecordDialog" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="myModalLabel1">新建报修</h4>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" id="new_maintenancerecord_form">
                    <div class="form-group">
                        <label for="new_equipmentId" class="col-md-auto control-label">
                            设备编号
                        </label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="new_equipmentId" placeholder="设备编号" name="equipmentId" readonly/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="new_description" class="col-md-auto control-label">报修内容</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="new_description" placeholder="报修内容" name="description" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="new_status1" class="col-md-auto control-label">状态</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="new_status1" placeholder="状态" name="status" readonly/>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="createMaintenanceRecord()">提交建议</button>
            </div>
        </div>
    </div>
</div>
<!-- 引入js文件 -->
<script src="<%=basePath%>js/jquery-1.11.3.min.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="<%=basePath%>js/bootstrap.js"></script>
<!-- Bootstrap-bundle JavaScript -->
<script src="<%=basePath%>js/bootstrap.bundle.js"></script>
<!-- Metis Menu Plugin JavaScript -->
<script src="<%=basePath%>js/metisMenu.min.js"></script>
<!-- DataTables JavaScript -->
<script src="<%=basePath%>js/jquery.dataTables.min.js"></script>
<script src="<%=basePath%>js/dataTables.bootstrap.min.js"></script>
<!-- Custom Theme JavaScript -->
<script src="<%=basePath%>js/sb-admin-2.js"></script>
<!-- 编写js代码 -->
<script type="text/javascript">
//清空新建窗口中的数据
    function clearFeedBack() {
        $("#new_userId").val("");
        $("#new_content").val("");
        $("#new_status").val("")
    }
    function clearMiantenanceRecord(id) {
            $("#new_equipmentId").val(id);
            $("#new_description").val("");
            $("#new_status1").val("未处理")
        }
 // 创建
    function createFeedBack() {
        $.post("<%=basePath%>feedback",
            $("#new_feedback_form").serialize(), function (data) {
                if (data == "OK") {
                    alert("建议创建成功！");
                    window.location.reload();
                } else {
                    alert("建议创建失败！");
                    window.location.reload();
                }
            });
    }
    function createMaintenanceRecord() {
            $.post("<%=basePath%>maintenance",
                $("#new_maintenancerecord_form").serialize(), function (data) {
                    if (data == "OK") {
                        alert("建议创建成功！");
                        window.location.reload();
                    } else {
                        alert("建议创建失败！");
                        window.location.reload();
                    }
                });
        }
</script>
</body>
</html>
